﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace Data_Access_Layer
{
    public class DataAccess
    {
        public SqlConnection GetConnect()
        {
            return new SqlConnection(@"Data Source=Mra-PC\SQLEXPRESS;Initial Catalog=QLBH;Integrated Security=True");
        }
        //Create a method return 1 database
        public DataTable GetTable(string sql)
        {
            SqlConnection con = GetConnect();
            SqlDataAdapter ad = new SqlDataAdapter(sql, con);
            DataTable dt = new DataTable();
            ad.Fill(dt);
            return dt;                 
        }
        //Create 1 method execute return result, use to insert, update, delete in SQL Query
        public void ExcuteNonQuery(string sql)
        {
            SqlConnection con = GetConnect();
            con.Open();
            SqlCommand cmd = new SqlCommand(sql, con);
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            con.Close();
        }
      //When we build then it create a dll file
    }
}
